<%@page import="fr.vahren.sriksal.controller.bean.UserInfo"%>



<p>Here are the available MAPS for you:
</p>

<table id="mapList">

</table>

<script type="text/javascript">

window.addEventListener('load', eventWindowLoaded, false);
function eventWindowLoaded() {
   getMapList();
}

function getMapList(){
	requestJSON('game/retrieveAvailableMapList',function(res){
		var mapList = JSON.parse(res).maps;
		fillList(mapList);
	});
}

function fillList(mapList){
	var table = '';
	for(var id in mapList){
		table += '<tr><td>Map id='+mapList[id][0]+'</td><td>User id='+mapList[id][1]+'</td><td><button onclick="javascript:joinMap('+mapList[id][0]+')">JOIN</button></td></tr>';
	}
	console.log(table);
	setText('mapList',table);
}

function joinMap(id){
	window.location.href = "game/chooseMap?mapId="+id;
}

</script>